<!DOCTYPE html>
<html class="um landscape min-width-240px min-width-320px min-width-480px min-width-768px min-width-1024px">
    <head>
        <title><!--智能监控查询--></title>
        <meta charset="utf-8">
        <meta name="viewport" content="target-densitydpi=device-dpi, width=device-width, initial-scale=1, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
        <link rel="stylesheet" href="css/ui-base.css">
        <link rel="stylesheet" href="css/ui-box.css">
        <link rel="stylesheet" href="css/project/ui-color-v3.css">
        <link rel="stylesheet" href="css/project/style.css">
        <link rel="stylesheet" href="css/zv_common.css">
        <script src="js/zy_control.js">
        </script>
        <script src="js/zy_click.js">
        </script>
        <script src="js/zy_json.js">
        </script>
        <script src="js/main.js">
        </script>
        <script src="js/init.js">
        </script>
        <script  src="js/JsonSQL/jsonsql-0.1.js"></script>
<script  src="js/jquery-1.11.1.min.js"></script>
<script src="js/talkingdata.js"></script>
        <style type="text/css">
            .topbg {
                background: #789de2;
            }
            
            .imatopline {
                border-bottom: 1px solid #789de2
            }
            
            .addSelectBg {
                background: #dddddd
            }
            
            .siteline {
                border:1px solid #789de2; width:4.5em; font-size:0.9em
            }
            
            .imatopge {
                border:1px solid #789de2;
                width: 2.9em;
                height: 1.8em;
                line-height: 1.8em;
                margin: 0.5em;
				font-size:0.9em
            }
        </style>
    </head>
    <body class="um-vp nobg " ontouchstart style="background:#fff">
        <div id="page_0" class="ub ub-ver um-vp">
            <div id="selectArea" style=" height:2.5em; line-height:2.5em; text-align:center; background:#e8e8e8; font-size:0.9em;">
                请选择区域
            </div>
            <div id="site">
            </div>
        </div>
    </body>
    <script>
        zy_init();
		function loadAreaX()
		{
			IC.talkingDataCount("智能监控","0019");
			//共选择几个区域
			var extarea = localStorage.getItem("zv_SelectArea");
			extarea = extarea.split(";");
			
			var extarealen = extarea.length;
			
			if(extarealen==0||extarea=="")
			{
				$$("selectArea").innerHTML = "请选择区域";
			}
			else
			{
				$$("selectArea").innerHTML = "共选了个"+extarealen+"区域";
			}
		}
		 function hasClass(obj,cls){
            return obj.className.match(new RegExp('(\\s|^)' + cls + '(\\s|$)'));
        }
        
        function addClass(obj,cls){
            if (!this.hasClass(obj, cls)) 
                obj.className += " " + cls;
        }
         
        function removeClass(obj, cls){
            if (hasClass(obj, cls)) {
                var reg = new RegExp('(\\s|^)' + cls + '(\\s|$)');
                obj.className = obj.className.replace(reg, ' ');
            }
        }
		 function siteadd(id,pid){
		 	IC.talkingDataCount("智能监控","0019");
		 	
			var extarea = localStorage.getItem("zv_SelectArea");
			var isSelect = $("#area_"+id).attr("class");
           // var isSelect = hasClass(obj,"addSelectBg");
		   if(isSelect.indexOf("addSelectBg")!="-1")
		   {
		   		$("#PID_"+pid).removeClass("addSelectBg");
				localStorage.setItem("IS_AllSelect_"+pid,"");
		   		$("#area_"+id).removeClass("addSelectBg");
		   }
		   else
		   {
		   		//$("#PID_"+pid).addClass("addSelectBg");
		   		$("#area_"+id).addClass("addSelectBg");
		   }
			//alert(isSelect);
            ueppscript("intelligent_monitoring_search", "content", "setarea('" + id + "')");
            
           // ueppscript("intelligent_monitoring_search", "content", "zv_SelectAreaSet()");
        }
        
        function OpenAreaIma(Name, Icon){
			IC.talkingDataCount("智能监控","0019");
            localStorage.setItem("siteName", Name);
            localStorage.setItem("siteIcon", Icon);
            openNewWin('site', 'site.html')
        }
       
         var extarea = localStorage.getItem("zv_SelectArea");
	
        function ischecked(id){
            var ishave = false;
           
			//alert(extarea);
			if(extarea!=null)
			{
				
		
            //			
            var aearArr = extarea.split(";");
            //			
            for (var i = 0; i < aearArr.length; i++) {
                if (id == aearArr[i]) {
                    ishave = true;
                }
            }
				}
            return ishave;
        }
		function setAddCssSelectAll(id)
		{
			IC.talkingDataCount("智能监控","0019");
			var extarea = localStorage.getItem("zv_SelectArea");
			//var isSelect = $("#area_"+id).attr("class");
		  	$("#area_"+id).addClass("addSelectBg");
		}
		function setRemoveCssSelectAll(id)
		{
			IC.talkingDataCount("智能监控","0019");
			//alert(id);
			var extarea = localStorage.getItem("zv_SelectArea");
			//var isSelect = $("#area_"+id).attr("class");
		  	$("#area_"+id).removeClass("addSelectBg");
		}
        function setAllSelect(id,par,pid)
		{
			IC.talkingDataCount("智能监控","0019");
			localStorage.setItem("AllSelectqiaowei",'1');
			
			var s=localStorage.getItem("IS_AllSelect_"+id);
			var extarea = localStorage.getItem("zv_SelectArea");
			var isSelectPID = $("#PID_"+id).attr("class");
			//alert(isSelectPID.indexOf("addSelectBg"));
           // var isSelect = hasClass(obj,"addSelectBg");
		   if(isSelectPID.indexOf("addSelectBg")!='-1')
		   {
		   			//取消全选
				localStorage.setItem("IS_AllSelect_"+id,"");
				ueppscript("intelligent_monitoring_search", "content", "setAllarea('remove','" + par + "')");
		   		$("#PID_"+id).removeClass("addSelectBg");
		   }
		   else
		   {
		   		//设置全选
				localStorage.setItem("IS_AllSelect_"+id,"1");
		   	ueppscript("intelligent_monitoring_search", "content", "setAllarea('add','" + par + "')");
		   		$("#PID_"+id).addClass("addSelectBg");
		   }
		   
		}
        window.uexOnload = function(type){
            if (!type) {
                uexWindow.setBounce("0");
				IC.talkingDataCount("智能监控","0019");
            }
			Loading(1500);
			for(var i = 100;i<250;i++)
			{
				 //localStorage.setItem("IS_AllSelect_"+i,"");
			}
           
          
            
			
			loadAreaX();
            $.getJSON("data/Category.json", function(jjson){
				
                var str = ''
				var siteIsSelected = localStorage.getItem("siteIsSelected");
				if(siteIsSelected.indexOf("SHA")!="-1")
				{
					var res = jsonsql.query("select * from json.data.items where (ID=='114' ||  ID=='118') order by OrderBy asc", jjson);
				}
                else
				{
					var res = jsonsql.query("select * from json.data.items where ( ID=='177' || ID=='186') order by OrderBy asc", jjson);
				}
				
                for (var i = 0; i < res.length; i++) {
				
                    str += '<div class="ub zv_hh imatopline" style="padding:0.5em 0.5em 0 0.5em;">'
                    str += '<div class="umw6  uc-t topbg tx-c t-wh">' + res[i].Name + '</div>'
                    str += '<div class="ub ub-f1">'
                    str += '<div class="ub-f1 tx-r">' + res[i].Name + ' 示意图</div>'
                    str += '<div style="width:2em;margin-left:0.5em; padding-top:0.3em;" onClick="OpenAreaIma(\'' + res[i].Name + '\',\'' + res[i].Icon + '\')"><img src="images/map.png"  style="width:1.5em"/></div>'
                    str += '</div>'
                    str += '</div>'
                    var siteres = jsonsql.query("select * from json.data.items where (PID=='" + res[i].ID + "' )  order by OrderBy asc", jjson);
                    for (var s = 0; s < siteres.length; s++) {
						  var Code = siteres[s].Code;
                        str += '<div class="ub imatopline" style="padding:0.25em 0">'
						
						//获取当前是否全选
						var IS_AllSelect = localStorage.getItem("IS_AllSelect_"+siteres[s].ID);
						var cssAll = "";
					
						if(IS_AllSelect=="1")
						{
							cssAll = "addSelectBg";
						}
						
						//防止换桥位不变色
						var AllSelectqiaowei= localStorage.getItem("AllSelectqiaowei");
						if(AllSelectqiaowei!=1)
						{
							cssAll = "";
						}
						
                        str += '<div class="'+cssAll+' umw4 siteline tx-c" onclick="setAllSelect('+siteres[s].ID+',\''+Code+'\',\''+siteres[s].PID+'\')" id="PID_'+siteres[s].ID+'" style="height:1.8em;margin:0.5em;line-height:1.8em;">' + siteres[s].Name + '</div>'
                        str += '<div class="ub-f1">'
                        str += '<ul>'
                          if (Code != '') {
						  	
                            if (Code.indexOf("-") > 0) {
                                if (Code.indexOf("#") > 0) {
                                    var node = Code.split("#");
                                    for (var n = 0; n < node.length; n++) {
                                        var nodea = node[n].split("-");
                                        for (var na = nodea[0]; na <= nodea[1]; na++) {
											 var css = "selectAll_"+siteres[s].ID;
	                                        if (ischecked(na)) {
	                                            css+= " addSelectBg";
	                                        }
											
											 str += '<li onclick=siteadd("'+na+'","'+siteres[s].ID+'") id="area_'+na+'" class="ufl imatopge tx-c '+css+'" ontouchstart="zy_touch(\'zv-btn-act\')">' + na + '</li>'
                                        }
                                    }
                                }
                                else {
                                    var nodea = Code.split("-");
                                    //alert(Code+":"+nodea.length)
                                    //alert(nodea[0])
                                    var startNum = parseInt(nodea[0]);
                                    var endNum = parseInt(nodea[1]);
                                    for (var na = startNum; na <= endNum; na++) {
                                        var nn = na
                                        if (siteres[s].PID == 177 || siteres[s].PID == 186) {
                                            if (na < 100 && na > 9) {
                                                nn = 0 + '' + na
                                            }
                                            if (na < 10) {
                                                nn = 0 + '0' + na
                                            }
                                        }
                                        var css = "selectAll_"+siteres[s].ID;
                                        if (ischecked(nn)) {
                                            css+= " addSelectBg";
                                        }
										
                                        str += '<li onclick=siteadd("'+nn+'","'+siteres[s].ID+'") id="area_'+nn+'"  class="ufl imatopge tx-c ' + css + '"  ontouchstart="zy_touch(\'zv-btn-act\')">' + nn + '</li>'
                                    }
                                }
                            }
                           
                                if (Code.indexOf("/") > 0) {
                                    var nodeb = Code.split("/");
                                    for (var nb = 0; nb < nodeb.length; nb++) {
                                       	var css = "selectAll_"+siteres[s].ID;
                                        if (ischecked(nodeb[nb])) {
                                            css += " addSelectBg";
                                        }
                                      	str += '<li onclick=siteadd("'+nodeb[nb]+'","'+siteres[s].ID+'") id="area_'+nodeb[nb]+'"  class="ufl imatopge tx-c ' + css + '" ontouchstart="zy_touch(\'zv-btn-act\')">' + nodeb[nb] + '</li>'
                                    }
                                }
                        }
                        str += '</ul>'
                        str += '</div>'
                        str += '</div>'
                    }
                }
                $$("site").innerHTML = str;
				
            });
        }
        
        
       
    </script>
</html>
